package com.example.demo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@RequestMapping("/respond")
@Controller
//RestController和Controller的区别
//RestController  表示数据           RestController=Controller+ResponseBody
//Controller   表示页面
//requestBodey   传递Json
public class response {
    @RequestMapping("/index")
    public String index(){
        return "/index.html";  //如果这里不加斜杠,访问的路径是request/index.html
    }


    //返回html代码片段
    @ResponseBody
    @RequestMapping("/getHtml")
    public String getHtml(){
        return "html";
    }

    @ResponseBody
    @RequestMapping("/returnJson")
    public User returnJson(){
        User user=new User("zhangsan","12345",10);
        return user;
    }


}

